<?php

/**
 * receipt actions.
 *
 * @package    sftest
 * @subpackage receipt
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 2692 2006-11-15 21:03:55Z fabien $
 */
class receiptActions extends sfActions
{
    /**
     * Executes index action
     *
     */
    public function executeIndex()
    {
        // ClientAuth 認証用のパラメータ
        $service = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
        $user = "mis19nishi@gmail.com";
        $pass = "dzv65c2t1hhkqjcouzzjuoxzll1754e1w9wqz0ipax35rr8c5okptwy2cx8bay1xnplfqtsxtx985h8jbrncqhx2k3lyet9pqulc";

        // 認証済みの HTTP クライアントを作成します
        $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);

        // サービスのインスタンスを作成します
        $service = new Zend_Gdata_Photos($client);

        //ここから↓参考ソースでのテスト
        $query = new Zend_Gdata_Photos_AlbumQuery();
        $query->setUser($user);
        $query->setAlbumName("receipt_test");
        $query->setType("feed");


        //userFeedを読み込んでる部分
        try{
            $albumFeed = $service->getAlbumFeed($query);

            $count = 0;
            foreach($albumFeed as $entry){
                $count++;
                $thumbnail = $entry->getMediaGroup()->getThumbnail();
                $imageUrl[] = $thumbnail[1]->url;
            }
        }catch(Zend_Gdata_App_HttpException $e){
            echo "Error: ".$e->getMessage()."<br>\n";
            if ($e->getResponse() != null) {
                echo "Body: <br />\n" .$e->getResponse()->getBody().
            "<br />\n";
            }
        }catch(Zend_Gdata_App_Exception $e){
            echo "Error: " .$e->getMessage(). "<br />\n";
        }

        //サムネイル画像の表示


        for($i=0; $i<$count; $i++){
            print "<img src=".$imageUrl[$i].">";
        }


        return sfView::SUCCESS;
        //$this->forward('default', 'module');
    }
}
